Passed
Push — master ( ecb34d...b8eee1 )
by Maxence
02:13
created

pico_define.init   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
nc 2
nop 0
1
/*
2
 * CMS Pico - Integration of Pico within your files to create websites.
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2017
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
27
/** global: OC */
28
/** global: OCA */
29
/** global: oc_config */
30
/** global: Notyf */
31
/** global: pico_elements */
32
/** global: pico_nav */
33
/** global: pico_result */
34
35
var pico_define = {
36
	sites: '/sites/',
37
	index: '',
38
	nchost: '',
39
40
	init: function () {
41
		pico_define.nchost = window.location.protocol + '//' + window.location.host;
42
43
		pico_define.index = OC.getRootPath();
44
		if (oc_config.modRewriteWorking !== true) {
45
			pico_define.index += '/index.php';
46
		}
47
	}
48
};
49
50
51
$(document).ready(function () {
52
53
	/**
54
	 * @constructs CMSPico
55
	 */
56
	var CMSPico = function () {
57
58
		$.extend(CMSPico.prototype, pico_nav);
59
		$.extend(CMSPico.prototype, pico_elements);
60
		$.extend(CMSPico.prototype, pico_result);
61
62
		pico_define.init();
63
		pico_elements.init();
64
65
		pico_nav.retrieveWebsites();
66
	};
67
68
	/**
69
	 * @constructs Notification
70
	 */
71
	var Notification = function () {
72
		this.initialize();
73
	};
74
75
	Notification.prototype = {
76
77
		initialize: function () {
78
79
			var notyf = new Notyf({
80
				delay: 5000
81
			});
82
83
			this.onSuccess = function (text) {
84
				notyf.confirm(text);
85
			};
86
87
			this.onFail = function (text) {
88
				notyf.alert(text);
89
			};
90
91
		}
92
93
	};
94
95
	OCA.CMSPico = CMSPico;
96
	OCA.CMSPico.manage = new CMSPico();
97
98
	OCA.Notification = Notification;
99
	OCA.notification = new Notification();
100
101
});
102